<?php
    if (!defined('EXPONENT')) exit('');
    if (exponent_users_isAdmin() ||  exponent_permissions_check(array("administrate"),$loc))
    {
        if (isset($_REQUEST['id']))
        {
            $id=intval($_REQUEST['id']);
            $email=$db->selectObject('mailsystem_email','id = '.$id);
            if ($_REQUEST['block']==1&&$email->block==0)
            {
                $email->block=1;
            }
            else 
            {
                if($email->block==1)
                {
                    $email->block=0;
                    $email->count_error=0;
                }
                else
                {
                    $noupdate=true;
                }
            }
            if(!$noupdate)
                $db->updateObject($email,'mailsystem_email','id = '.$id);

        }
        echo "OK";
    }
    else
        exponent_http_error(403);
?>
